package cn.tedu.jdbc;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class JdbcTest {
    public static void main(String[] args) {
/*        new TestJDBC1().insert("insert into q values(?,?)",100,99);
        System.out.println("插入成功");*/
/*        TestJDBC1 testJDBC1 = new TestJDBC1();
        testJDBC1.change("delete from q where id=?",100);*/
        TestJDBC1 testJDBC1 = new TestJDBC1();

        StringBuffer stringBuffer = new StringBuffer();
        BufferedReader bufferedReader = null;
        try {
            bufferedReader = new BufferedReader(new FileReader("G:\\Project01\\试题\\test.txt"));
            char a[] = new char[5000];
            int b = 0;
            while ((b = bufferedReader.read(a, 0, a.length)) != -1) {
                for (int i = 0; i < b; i++) {
                    stringBuffer.append(a[i]);
                }
            }
            String s = new String(stringBuffer);
            String[] split = s.split("%");
            System.out.println(split.length);
          //  StringBuffer stringBuffer1 = new StringBuffer("insert into glz values(null,?)");
            for (int i = 0; i < split.length; i++) {
            //  stringBuffer1.append(",(null,?)");
                testJDBC1.change("insert into glz values(null,?)", split[i]);
            }
           // String s1 = new String(stringBuffer1);
           // testJDBC1.change(s1, split);
            System.out.println("本地文件导入数据库成功");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {

            if (bufferedReader != null) {
                try {
                    bufferedReader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }


}
